// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import iView from 'iview';
import axios from 'axios'
import echarts from 'echarts'
require('echarts/theme/hengyi');

// 引入样式
import 'vue-easytable/libs/themes-base/index.css'
import 'iview/dist/styles/iview.css';
import '../static/css/animate.css'
import '../static/icon/alicon/iconfont.css'
import '../static/css/all.css'
import './style.less'

import store from './store.js'
import './components/js/Permission.js'

// 导入 table 和 分页组件
import {VTable,VPagination} from 'vue-easytable'
import { getlocalstorage, getsessionstorage } from "@/components/js/Localstorage.js"
Vue.component(VTable.name, VTable)
Vue.component(VPagination.name, VPagination)

Vue.use(iView);
Vue.prototype.$http = axios
Vue.prototype.$echarts = echarts 

Vue.config.productionTip = false



/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  components: { App },
  template: '<App/>'
})

axios.interceptors.request.use(
	config => {	
		var token = getsessionstorage("authorization");
		if(token) {
			config.headers.Authorization = token;
		}else{
			config.headers.Authorization = "666";
		}
		return config
	},
	error => {
		return Promise.reject(error)
	});
	
axios.interceptors.response.use(
  response => {
  	if(response.data.code == "RE_ENTRY"){
  		router.replace({path: '/login'})
  	}
    return response
  },
  error => { 
    return Promise.reject(error.response)
  }
)